<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>lightBlog</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="author" content="Zhigang Song">

    <!-- Custom CSS -->
    <link rel="stylesheet" href="/asset/css/main.css" type="text/css">
    <link rel="stylesheet" href="/asset/css/admin-article.css" type="text/css">

    <!-- Fonts -->
    <link href='//fonts.useso.com/css?family=Merriweather:900,900italic,300,300italic' rel='stylesheet' type='text/css'>
    <link href='//fonts.useso.com/css?family=Lato:900,300' rel='stylesheet' type='text/css'>
    
    <link rel="stylesheet" href="/asset/vendor/pagedown/css/demo.css" type="text/css">
    <link rel="stylesheet" href="/asset/vendor/prettify/prettify.css" type="text/css">

</head>

<body class="">
    <div class="site-wrap">

        <?php include(dirname(__DIR__) . '/header.php'); ?>

        <div class="post p2 p-responsive wrap" role="main">
            <div class="measure">


                <div class="post">

                    <header class="post-header">
                        <h1 id="admin-new-post" class="h2">New Post</h1>
                    </header>
                    <article class="post-content">
                        <div class="py2">
                            <form action="<?php echo route('article', 'new_article'); ?>" method="POST" class="form-stacked form-light">
                                <input type="text" name="title" class="input mobile-block" placeholder="Post title here" />
                                <?php
                                foreach ($category as $key => $value) {
                                    $id = $value['id'];
                                    $name = $value['name'];
                                    $remark = $value['remark'];
                                    echo "<input type='checkbox' value='$id' name='category[]' />$name($remark)";
                                }
                                ?>
                                <br />
                                <?php
                                foreach ($tags as $key => $value) {
                                    $id = $value['id'];
                                    $name = $value['name'];
                                    $remark = $value['remark'];
                                    echo "<input type='checkbox' value='$id' name='tags[]' />$name($remark)";
                                }
                                ?>

                                <div class="wmd-panel">
                                    <div id="wmd-button-bar"></div>
                                    <textarea type="text" name="content" class="input mobile-block wmd-input" id="wmd-input" placeholder="Your article content here ..."></textarea>
                                </div>
                                <div id="wmd-preview" class="wmd-panel wmd-preview hidden"></div>

                                <input type="submit" class="button button-blue mobile-block" value="Publish">
                            </form>
                        </div>

                    </article>

                </div><!-- end of .post -->

            </div><!-- end of .measure -->
        </div><!-- end of .post -->
    </div><!-- end of .site-wrap -->

    <?php include(dirname(__DIR__) . '/footer.php'); ?>

    <script type="text/javascript" src="/asset/vendor/pagedown/js/Markdown.Converter.js"></script>
    <script type="text/javascript" src="/asset/vendor/pagedown/js/Markdown.Sanitizer.js"></script>
    <script type="text/javascript" src="/asset/vendor/pagedown/js/Markdown.Editor.js"></script>
    <script type="text/javascript" src="/asset/vendor/prettify/prettify.js"></script>
    <script type="text/javascript" src="/asset/vendor/pagedown/js/Markdown.Extra.js"></script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.5.3/MathJax.js?config=TeX-AMS_HTML"></script>

    <script type="text/javascript">
        (function() {
            var converter1 = Markdown.getSanitizingConverter();
            Markdown.Extra.init(converter1, {
                extensions: "all",
                highlighter: "prettify"
            });

            converter1.hooks.chain("preBlockGamut", function(text, rbg) {
                return text.replace(/^ {0,3}""" *\n((?:.*?\n)+?) {0,3}""" *$/gm, function(whole, inner) {
                    return "<blockquote>" + rbg(inner) + "</blockquote>\n";
                });
            });
            var editor1 = new Markdown.Editor(converter1);
            editor1.hooks.chain("onPreviewRefresh", prettyPrint); // google code prettify
            editor1.run();

        })();
    </script>

</body>

</html>
